import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:provider/provider.dart';
import 'package:provider_demo/model/somemodel.dart';

class ModelRatingBarConsumer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<SomeModel>(builder: (context, model, widget) {
      return Row(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          FlutterRatingBar(
            initialRating: model.rating,
            fillColor: Colors.amber,
            borderColor: Colors.amber.withAlpha(50),
            allowHalfRating: true,
            ignoreGestures: true,
            onRatingUpdate: null,
            itemCount: 5,
            itemSize: 28,
          ),
          SizedBox(
            width: 12,
          ),
          Text(
            model.rating.toString(),
            style: TextStyle(
                fontSize: 24, color: Colors.amber, fontWeight: FontWeight.w600),
          )
        ],
      );
    });
  }
}
